<?php
require_once dirname(__FILE__).'/../../productPage/lib/ProductPageHelper.class.php';
class productsComponents extends myComponents{

        public function executeRender($request) {
            
            $this->groups = ProductGroupTable::getInstance()->findSaleshouseGroups();
            //echo '<pre>';print_r($this->groups->toArray());exit;
            
            $this->groupLinks = LinkGen::getInstance(LinkGen::PRODUCT_GROUP)->collectionLinks($this->groups);
            $this->productPageHelper = new ProductPageHelper();
        }
    
	public function vana(){
		$q = Doctrine_Query::create()
			->from('Product p')
			->select('p.*, pt.*, pp.*')
			->innerJoin('p.ProductGroups pgvp')
//			->innerJoin('pgvp.ProductGroup pg WITH pg.parameter = ?', 'sales_top')
                        ->leftJoin('p.ProductPictures pp')
                        // Removed to avoid PG display in menu,
                        // check for structure is done with module connection
			//->innerJoin('pg.StructureProductGroup spg')
			//->innerJoin('spg.Structure s WITH s.id = ?', $this->getRoute()->getObject()->getId())
			->innerJoin('p.Translation pt WITH pt.lang = ? AND pt.name != ""', $this->getUser()->getCulture())
			->limit(12)
			->orderBy('p.pri asc')
			->setHydrationMode(Doctrine::HYDRATE_ARRAY);

		$this->products = $q->execute();
		$this->productLinks = LinkGen::getInstance(LinkGen::PRODUCT)->collectionLinks($this->products);
		$this->productPageHelper = new ProductPageHelper();
	}
}